package cn.bailan.utils;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * Author:甲粒子
 * Date: 2022/3/31
 * Description：时间生成工具类
 */
public class TimeUtil {
    public static final SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
    public static final SimpleDateFormat sdf2 = new SimpleDateFormat("yyyy/MM/dd");

    public static String getNowTime(){
        return sdf2.format(new Date());
    }
    public static String getTime(){
        return sdf1.format(new Date());
    }
    public static String yesterday(){
        Date today = new Date(System.currentTimeMillis() - 1000 * 60 * 60 * 24);
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy/MM/dd");
        String yesterday = simpleDateFormat.format(today);//获取昨天日期
        return yesterday;
    }
}
